package com.cloud.multiClientSocket;

import java.io.IOException;
import java.net.*;

public class MyClient {
    public static void main(String[] args) throws IOException {
        //udp使用12345端口发出udp消息
        DatagramSocket ds = new DatagramSocket(12345);
        String str_send = "Hello";
        InetAddress loc = InetAddress.getLocalHost();
        //udp发送到服务器的5555端口
        DatagramPacket dp_send = new DatagramPacket(str_send.getBytes(), str_send.length(), loc, 5555);
        ds.send(dp_send);
        //tcp使用12345端口发送到服务器的5555端口
        Socket socket = new Socket("127.0.0.1", 5555, null, 12345);

        //报错java.net.BindException: Address already in use: JVM_Bind
        Socket socket1 = new Socket("127.0.0.1", 5555, null, 12345);
    }

}
